<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <ul style="list-style:none"></ul>
    <script>
        let ul = document.querySelector('ul');
        let ajax = new XMLHttpRequest();
        ajax.open('get', '/shopping');
        ajax.send();
        ajax.onreadystatechange = function () {
            if (ajax.readyState == 4 && ajax.status == 200) {
                let arr = JSON.parse(ajax.responseText).data;
                let str = '';
                arr.forEach(item => {
                    str += `<li>
                    <img src='${item.picture}'>
                    <p>${item.tradeName}</p>
                    <p>单价：${item.price}</p>
                    <p>数量：${item.stock}</p>
                    </li>`;;
                })
                ul.innerHTML = str;
            }
        }
    </script>
</body>

</html>